package my.tutorial.javacore.test.analytic;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * Java Test 1 Regular expressions
 */
public class MyExpression {

	public static final String expression="(^|\\W)((heavy\\s)?damage|minor\\sdamages)(\\W|$)"; 
	
	/**
	 * Check if the input string matches our expression.
	 * @param input 
	 */
	public void check(String input){
		Pattern pattern = Pattern.compile(expression);
		Matcher matcher = pattern.matcher(input);
		if(matcher.find()){
			System.out.println("The given string: \""+input+"\" matches!");
		}else{
			System.out.println("The given string: \""+input+"\" does not match!");
		}
	}
	public static void main(String[] args) {
		MyExpression myExpression=new MyExpression();
		myExpression.check("damage");
		myExpression.check("heavy damage");
		myExpression.check("minor damages");
		myExpression.check("no damages");
	}
}
